﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Restaurant.Dto
@model IPagedList<RestaurantTypeNumberListDto>
@{
    Layout = null;
    int count = 0;
    int x = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {

            x = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
}
<div>

    <table class="table table-bordered table-hover table-rowselected">
        <thead>
            <tr>
                <th style="width:45px">序号</th>
                <th>餐厅名称</th>
                <th>餐厅地址</th>
                <th>餐厅联系人</th>
                <th>联系人电话</th>
                <th>货品型号</th>
                <th>单价</th>
                <th style="width:200px;">操作</th>
            </tr>
        </thead>
        <tbody>
            @if (Model.Count == 0)
            {
                <tr><td class="text-center" colspan="8">暂无数据</td></tr>
            }
            else
            {
                foreach (var item in Model)
                {
                    x++;
                    count = item.typeNumberLists.Count;
                    int i = 0;
                    foreach (var chilitem in item.typeNumberLists)
                    {
                        <tr>
                            @if (i == 0)
                            {
                                <td rowspan="@count">@x</td>
                                <td rowspan="@count">@item.RestaurantName</td>
                                <td rowspan="@count">@item.RestaurantAddress</td>
                                <td rowspan="@count">@item.Name</td>
                                <td rowspan="@count">@item.Mobile</td>
                                <td>@chilitem.TypeNumberName</td>
                                <td>@chilitem.Price</td>
                                <td>
                                    <button class="btn btn-success btn-xs" data-toggle="modal" data-target="#modal_ajax" data-backdrop="static" data-url="@Url.Action("EditTypeNumberPrice", new { id = chilitem.Id })"><i class="fa fa-edit"></i>修改单价</button>
                                </td>
                            }
                            else
                            {
                                <td>@chilitem.TypeNumberName</td>
                                <td>@chilitem.Price</td>
                                <td>
                                    <button class="btn btn-success btn-xs" data-toggle="modal" data-target="#modal_ajax" data-backdrop="static" data-url="@Url.Action("EditTypeNumberPrice", new { id = chilitem.Id })"><i class="fa fa-edit"></i>修改单价</button>
                                </td>
                            }
                        </tr>
                        i++;
                    }
                }
            }
        </tbody>
    </table>

</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        共 @Model.TotalItemCount 条，@Model.PageSize 条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        @Html.PagedListPager(Model, page => Url.Action("DistributionDetails", new { pageIdx = page, key = 2 }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list1", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>